#include<stdio.h>
#include<stdlib.h>
#include<unistd.h>
#include<fcntl.h>
#include<string.h>
#include<pthread.h>

#include "memoryPool.h"


void test01()
{
    mempool_t mempool;
    memp_init(&mempool, 32);
    
    void* p1 = self_malloc(&mempool, 5);
    printf("p1 = %p\n", p1);
    
    void* p2 = self_malloc(&mempool, 10);
    printf("p2 = %p\n", p2);

    void* p3 = self_malloc(&mempool, 15);
    printf("p3 = %p\n", p3);

    void* p4 = self_malloc(&mempool, 20);
    printf("p4 = %p\n", p4);
    
    self_free(&mempool, p1);
    printf("ptr = %p\n", mempool.ptr);


    self_free(&mempool, p3);
    printf("ptr = %p\n", mempool.ptr);


    void* p5 = self_malloc(&mempool, 5);
    printf("p5 = %p\n", p5);

    void* p6 = self_malloc(&mempool, 5);
    printf("p6 = %p\n", p6);
}


void test02()
{
    mempool_t mempool;
    memp_init(&mempool, 32);
    
    int* p1 = (int*)self_malloc(&mempool, 5);
    printf("p1 = %p\n", p1);
    *p1 = 10;
    printf("p1 = %p\n", p1);
    

    void* p2 = self_malloc(&mempool, 10);
    printf("p2 = %p\n", p2);
    


}

int main(void)
{
   // test01();
    test02();


    return 0;
}
